import uuid
from Config import *
from mySocket import *
import json


class terminal:
    def __init__(self):
        if getConfig("client.config", "all", "mac") == get_mac_address():
            return
        setConfig("client.config", "all", "mac", get_mac_address())
        terminalSocket = mySocket(getConfig('client.config', 'socket', 'host'),
                                  int(getConfig('client.config', 'socket', 'port')))
        data = {'MAC': get_mac_address(), 'location': getConfig("client.config", "all", "location")}
        terminalSocket.socketSend(bytearray(json.dumps(data).encode('utf-8')), 0)
        print(terminalSocket.socketReceive())
        pass


def get_mac_address():
    mac = uuid.UUID(int=uuid.getnode()).hex[-12:]
    return ":".join([mac[e:e + 2] for e in range(0, 11, 2)])

# a=terminal()
